<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "attachment".
 *
 * @property integer $id
 * @property string $archive_id
 * @property integer $type
 * @property string $description
 */
class Attachment extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'attachment';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['archive_id'], 'required'],
            [['archive_id', 'type'], 'integer'],
            [['description'], 'string'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'archive_id' => 'Archive ID',
            'type' => 'Type',
            'description' => 'Description',
        ];
    }

    public function getUploadFile()
    {
        return $this->hasMany(UploadFile::className(),['id'=>'id'])
            ->viaTable('rel_attachment_upload_file',['attachment_id'=>'id']);
    }
}
